<?php
/**
 * Created by PhpStorm.
 * User: 12297
 * Date: 2018/5/28
 * Time: 0:35
 */
namespace app\common\validate;

class MemberType extends BaseValidate{
    protected $rule = [
        'memType' => 'require|isNotEmpty',
        'selectImg' => 'require|isNotEmpty',
        'openStatus' => 'require|checkopenStatus',
        'rechargeOpenMoney' => 'checkmoney',
        'returnMoney' => 'checkmoney',
        'isIndefinite' => 'require|checkisIndefinite',
        'term' => 'isPositivenumber',
        'isMemBerShop' => 'checkisIndefinite',
        'memberDiscounts' => 'isPositivenumber',
        'tempPointStatus' => 'checkopenStatus3',
        'consumeMoney' => 'checkmoney',
        'consumeIntegral' => 'isPositivenumber',
        'rechargeMoney' => 'checkmoney',
        'rechargeIntegral' => 'isPositivenumber'

    ];

    protected $message = [
        'memType' => '会员类型名称不能为空',
        'selectImg' => '会员卡图案不能为空',
        'openStatus' => '开通条件类型不正确',
        'rechargeOpenMoney' => '开通条件-充值数值不合法',
        'returnMoney' => '返还金额不合法',
        'isIndefinite' => '会员期限类型不正确',
        'term' => '会员期限不合法',
        'isMemBerShop' => '会员权益类型不合法',
        'memberDiscounts' => '折扣数值不合法',
        'tempPointStatus' => '会员积分状态不合法',
        'consumeMoney' => '会员积分-消费金额不合法',
        'consumeIntegral' => '会员积分-积分不合法',
        'rechargeMoney' => '会员积分-充值金额不合法',
        'rechargeIntegral' => '会员积分-积分不合法'

    ];

    protected function checkopenStatus($value){
        if($value==1 || $value==2){
            return true;
        }else{
            return false;
        }
    }

    protected function checkopenStatus3($value){
        if($value==1){
            return true;
        }else{
            return false;
        }
    }
    protected function isPositivenumber($value){
        if (is_numeric($value) && ($value + 0) > 0)
        {
            return true;
        }
        else
        {
            return false;

        }
    }
    protected function checkisIndefinite($value){
        if($value==0 || $value==1){
            return true;
        }else{
            return false;
        }
    }
}